package com.gem.day07;

import com.gem.day06.extend1.*;

/**
 * 本类用来演示Java23种设计模式之工厂设计模式
 * 
 * @author easonsy
 * 2020年7月24日 下午1:58:02
 */
public class EmployeeFactory {

	//定义常量
	public static final int SALES_EMP = 1;
	public static final int SALARIED_EMP = 2;
	public static final int HOURLY_EMP = 3;
	public static final int BASED_PLUS_SALES_EMP = 4;

	public static Employee getInstance(int type) {
		Employee employee = null;
		if (type == SALES_EMP) {
			employee = new SalsEmployee();
		} else if (type == SALARIED_EMP) {
			employee = new SalariedEmployee();
		} else if (type == HOURLY_EMP) {
			employee = new HourlyEmployee();
		} else if (type == BASED_PLUS_SALES_EMP) {
			employee = new BasedPlusSalesEmployee();
		} else {
			throw new RuntimeException("参数不合法...");
		}
		return employee;
	}
}
